{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "# 第一天：基础知识",
   "id": "87af87c4b9970f83"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "## python代码的运行方式\n",
    "1. 控制台直接输 python 可以打开监护界面\n",
    "2. 控制台输入 python -i demo.py  可以执行py文件之后打开控制台\n",
    "3. python demo.py  可以直接执行py文件\n",
    "4. 交互模式只能使用exit() 函数退出\n"
   ],
   "id": "ae80c4c39858bae4"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-27T04:32:55.325381Z",
     "start_time": "2025-10-27T04:32:55.319571Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#  bool类的默认值是False\n",
    "a = bool()\n",
    "b = bool(0) # 数字类型 0 就是false ,其他都是true\n",
    "# 对于其他类型 非空是True 空是False\n",
    "b"
   ],
   "id": "9e8692f4b9378ece",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 4
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-27T04:39:47.589531Z",
     "start_time": "2025-10-27T04:39:47.585530Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 整型类\n",
    "# 0b0101 -> 二进制 0o42 -> 八进制 0x7F  -> 十六进制\n",
    "int(0x52)\n",
    "int() # 可以接 浮点数结果是整数部分 ， 可以接数值类型的字符串 结果是整数部分  如果不能转换成整数会报错 ValueError\n",
    "# 两个参数   第一个数据值 第二个   几进制     2 8 16 10"
   ],
   "id": "2af4ee9be7134582",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 17
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-27T04:41:09.423215Z",
     "start_time": "2025-10-27T04:41:09.419115Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 浮点型\n",
    "float()"
   ],
   "id": "1187d0df97b68a49",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 20
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "## 序列类型",
   "id": "c5b311dbadfffb2c"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "### 列表（List）",
   "id": "b8af99eaf04fb858"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-27T04:45:25.974387Z",
     "start_time": "2025-10-27T04:45:25.969055Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 初始化方法\n",
    "a = list()\n",
    "a = list([1,2]) # 参数可以传 字符串、列表、字典、集合、元组\n",
    "DICT1 = {\"NAME\":\"ZHANG\",\"age\":\"20\",\"sex\":\"1\"}\n",
    "list(DICT1.values()) # 传递字段只会把key初始化成一个列表\n",
    "list(\"我是世界上发中的\") # 传递字符串会产生一个单个字符的列表"
   ],
   "id": "f5085a38b853c675",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['我', '是', '世', '界', '上', '发', '中', '的']"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 31
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "### 元组\n",
   "id": "a8c616800bcfcd85"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-27T04:50:44.042457Z",
     "start_time": "2025-10-27T04:50:44.038729Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 初始化方法 ()\n",
    "type(())\n",
    "# 表示只有一个元素的元组时 必须加一个,号\n",
    "a = (1,)\n",
    "a"
   ],
   "id": "d1909bf2782d13f",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1,)"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 39
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "### str类\n",
   "id": "c7c45a27dea9a44"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-27T04:51:59.650905Z",
     "start_time": "2025-10-27T04:51:59.648095Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 初始话方式\n",
    "a = 'asd'\n",
    "c = \"asd\"\n",
    "b = \"\"\"dwadawd\"\"\"\n",
    "print(a,b,c)"
   ],
   "id": "4c0afa66ccbb5ae7",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "asd dwadawd asd\n"
     ]
    }
   ],
   "execution_count": 41
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "### set和frozenset类",
   "id": "870ad41c51e4608"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-27T04:54:46.620880Z",
     "start_time": "2025-10-27T04:54:46.614377Z"
    }
   },
   "cell_type": "code",
   "source": [
    "a = {}# 需要注意 不能使用{} 表示集合   这个是字典的初始化表示 只能使用 set()\n",
    "set()\n",
    "# forzenset类是不可变类型\n",
    "set ('dawdivhiudfoqiwfuifd')"
   ],
   "id": "b6407baffadae05",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'a', 'd', 'f', 'h', 'i', 'o', 'q', 'u', 'v', 'w'}"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 44
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "### 字典",
   "id": "93df6d3916f25710"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-27T04:57:49.852573Z",
     "start_time": "2025-10-27T04:57:49.847251Z"
    }
   },
   "cell_type": "code",
   "source": [
    "d = {\"name\":\"张三\",\"age\":\"28\"}\n",
    "d['name'] = \"里斯\"\n",
    "d\n",
    "# 还有一种构建方式\n",
    "d = dict([('name','张三'),('age','23')])\n",
    "d"
   ],
   "id": "86f15091cb75593b",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': '张三', 'age': '23'}"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 50
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
